home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
SAMDU240.ZIP
/
HANDLEST.C
< prev
next >
Wrap
Text File
|
1993-10-01
|
29KB
|
548 lines
/*********************************************************************/
/* */
/* Name: HANDLEST.C */
/* */
/* Copyright (c) Stewart A. Berman 1992, All rights reserved */
/* */
/*********************************************************************/
#pragma warning (disable:4001)
#include <Windows.h>
#pragma warning (default:4001)
#include <String.h>
#include "HandleSt.h"
#include "IOStatus.h"
#ifdef DEBUG
#include "DebugOut.h"
#endif
#ifdef _cplusplus
extern "C" {
#endif /* _cplusplus */
BOOL bTimerInterval ;
int FAR PASCAL HandleStatus ( UINT nStatus1, UINT nStatus2, UINT nParam1, UINT nParam2, LONG lParam1, LONG lParam2 )
{
/********************************************************************/
/* */
/* This is the callback function for disk activity status */
/* */
/* 1. Determine the type of callback (based on nStatus1) */
/* */
/* nStatus Action */
/* ------- ------ */
/* STATUS1_INIT Save hWnd and hInstance */
/* STATUS1_START Send USR_ACTIVE message */
/* STATUS1_BOOT_SECTOR Send USR_ACTIVE message */
/* STATUS1_DIRECTORY Send USR_ACTIVE message */
/* STATUS1_FAT Send USR_ACTIVE message */
/* STATUS1_SYSTEM_FILE Send USR_ACTIVE message */
/* STATUS1_CYLINDER Send USR_UPDATE message */
/* STATUS1_HEAD Ignore */
/* STATUS1_END Beep and/or Flash if option selected */
/* STATUS1_ERROR Error type dependent */
/* */
/********************************************************************/
static BOOL bFlash = FALSE ;
static BOOL bSound = FALSE ;
static HINSTANCE hInstance = NULL ;
static HWND hWnd = NULL;
static UINT nTimerInterval ;
static TIMERPROC lpfnSABDUTimerFunc ;
char czBuffer1[512] ;
char czBuffer2[512] ;
char czIconMessage[512] ;
char czNormalMessage[512] ;
STMESSAGE stMessage ;
STMESSAGE far *lpstMessage ;
MSG msg ;
/********************************************************************/
/* */
/* We want to be a well behaved Windows application so we need to */
/* let go of the CPU and let other applications get some work done. */
/* */
/********************************************************************/
while ( PeekMessage ( &msg, NULL, NULL, NULL, PM_REMOVE ) )
{
TranslateMessage ( &msg ) ;
DispatchMessage ( &msg ) ;
}
/********************************************************************/
/* */
/* The following is a multilevel switch for processing callback */
/* requests. */
/* */
/* The first level is seperates the major areas. Most of them are */
/* normal operation and are provided so the application can keep */
/* the user informed on the progress of long running tasks. */
/* Most of the first level messages are sent via SendMessage. */
/* The response is passed back to the routine issuing the callback */
/* requests. This allows the application to stop a long running */
/* process by returning an IDCANCEL in response to the SendMessage */
/* request. */
/* */
/* The second level is used to seperate the various types of error */
/* notifications. Some of them prompt the user for a decision as */
/* to whether or not a retry should be attempted. Others simply */
/* notify the user of a problem. */
/* */
/* The general method used to kept the user informed is to update */
/* two messages used by our WM_PAINT routine. One is used when the */
/* application is running in Iconic state and the other is for when */
/* it is not running in Iconic state. The messages are built here */
/* and passed in a structure via a SendMessage call to a routine */
/* that stores them where the WM_PAINT routine can access them. */
/* This maintains complete independence between this routine and */
/* the WM_PAINT routine. */
/* */
/********************************************************************/
#ifdef DEBUG
if ( pCDebugOut!=NULL )
{
wsprintf (
(LPSTR)DebugOutczDebugBuffer(),
(LPSTR)"Status1: %4.4X\n"
"Status2: %4.4X\n"
"nParam1: %4.4X\n"
"nParam2: %4.4X\n"
"lParam1: %8.8lX\n"
"lParam2: %8.8lX",
nStatus1,
nStatus2,
nParam1,
nParam2,
lParam1,
lParam2
) ;
DebugOutOutputIf ( 0x00000001, DebugOutczDebugBuffer(), "HandleStatus", MB_ICONINFORMATION|MB_OK ) ;
}
#endif
switch ( nStatus1 )
{
case STATUS1_INIT: /* User is passing hWnd, hInstance, and timer controls */
{
hWnd = (HWND)nParam1 ;
hInstance = (HINSTANCE)nParam2 ;
nTimerInterval = LOWORD ( lParam1 ) ;
bFlash = HIWORD ( lParam2 ) ;
bSound = LOWORD ( lParam2 ) ;
return ( FALSE ) ;
break ;
}
case STATUS1_START: /* We are starting a long running process */
{
wsprintf ( (LPSTR)czIconMessage, (LPCSTR)"%2.2d %3.2d%%", 0, 0 ) ;
stMessage.pIconMessage = czIconMessage ;
wsprintf ( (LPSTR)czNormalMessage, (LPCSTR)"Cylinder %2.2d (%3.2d%%)", 0, 0 ) ;
stMessage.pNormalMessage = czNormalMessage ;
stMessage.nPercentageToColor = 0 ;
lpstMessage = (STMESSAGE far *) &stMessage ;
return ( LOWORD (SendMessage ( hWnd, USR_ACTIVE, 0, (LONG)lpstMessage ) ) ) ;
break ;
}
case STATUS1_BOOT_SECTOR: /* We are installing a new boot sector */
{
_fstrcpy ( (LPSTR)czIconMessage, (LPCSTR)"Boot" ) ;
stMessage.pIconMessage = czIconMessage ;
_fstrcpy ( (LPSTR)czNormalMessage, (LPCSTR)"Installing Boot Sector" ) ;
stMessage.pNormalMessage = czNormalMessage ;
stMessage.nPercentageToColor = 100 ;
lpstMessage = (STMESSAGE far *) &stMessage ;
return ( LOWORD ( SendMessage ( hWnd, USR_ACTIVE, 0, (LONG)lpstMessage ) ) ) ;
break ;
}
case STATUS1_DIRECTORY: /* We are building a diskette directory */
{
_fstrcpy ( (LPSTR)czIconMessage, (LPCSTR)"DIR" ) ;
stMessage.pIconMessage = czIconMessage ;
_fstrcpy ( (LPSTR)czNormalMessage, (LPCSTR)"Creating Directory" ) ;
stMessage.pNormalMessage = czNormalMessage ;
stMessage.nPercentageToColor = 100 ;